<html>
<head><meta charset="utf-8"><title>clang in llvm-tools-preview? · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/clang.20in.20llvm-tools-preview.3F.html">clang in llvm-tools-preview?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="207499373"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/clang%20in%20llvm-tools-preview%3F/near/207499373" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/clang.20in.20llvm-tools-preview.3F.html#207499373">(Aug 20 2020 at 08:24)</a>:</h4>
<p>It looks like we have support for building clang from the bundled LLVM. How feasible would it be to build clang and ship it in llvm-tools-preview or a similar component? I'd be interested in making it easier to use a compatible clang for cross-language LTO. cc <span class="user-mention" data-user-id="124287">@mw</span></p>



<a name="207501178"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/clang%20in%20llvm-tools-preview%3F/near/207501178" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/clang.20in.20llvm-tools-preview.3F.html#207501178">(Aug 20 2020 at 08:47)</a>:</h4>
<p>I think I remember discussing this with <span class="user-mention" data-user-id="116015">@Alex Crichton</span> a while ago and, if I remember correctly, the main point of uncertainty was the availability of the C/C++ standard libraries on the installing system. I don't think there is any reason why this shouldn't work in principle though.</p>



<a name="207502014"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/clang%20in%20llvm-tools-preview%3F/near/207502014" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/clang.20in.20llvm-tools-preview.3F.html#207502014">(Aug 20 2020 at 08:57)</a>:</h4>
<p><span class="user-mention" data-user-id="124287">@mw</span> As in, the availability of those libraries for linking programs built with that toolchain?</p>



<a name="207502267"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/clang%20in%20llvm-tools-preview%3F/near/207502267" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/clang.20in.20llvm-tools-preview.3F.html#207502267">(Aug 20 2020 at 09:00)</a>:</h4>
<p>That makes sense. That's a much easier problem to solve than obtaining a matching version of clang that uses the same version of LLVM as Rust, though.</p>



<a name="207502440"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/clang%20in%20llvm-tools-preview%3F/near/207502440" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mati865 <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/clang.20in.20llvm-tools-preview.3F.html#207502440">(Aug 20 2020 at 09:02)</a>:</h4>
<p>LLVMs libc++ and compiler-rt+libunwind can be used to replace the need for GCC on host system for the main platforms like Linux and Windows (at least for MinGW, I don't know about MSVC).</p>



<a name="207502498"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/clang%20in%20llvm-tools-preview%3F/near/207502498" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/clang.20in.20llvm-tools-preview.3F.html#207502498">(Aug 20 2020 at 09:03)</a>:</h4>
<p>That wouldn't replace the need for libc headers, but yeah.</p>



<a name="207502605"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/clang%20in%20llvm-tools-preview%3F/near/207502605" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/clang.20in.20llvm-tools-preview.3F.html#207502605">(Aug 20 2020 at 09:04)</a>:</h4>
<p>It'd also make cross-compiling C code easier.</p>



<a name="207502680"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/clang%20in%20llvm-tools-preview%3F/near/207502680" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/clang.20in.20llvm-tools-preview.3F.html#207502680">(Aug 20 2020 at 09:05)</a>:</h4>
<p>What would it take to give this a try in nightly?</p>



<a name="207503732"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/clang%20in%20llvm-tools-preview%3F/near/207503732" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/clang.20in.20llvm-tools-preview.3F.html#207503732">(Aug 20 2020 at 09:20)</a>:</h4>
<p>I'm not really up-to-date but it looks like we are still already building clang on at least <code>x86_64-unknown-linux-gnu</code> in order to run the xLTO end-to-end tests.</p>



<a name="207503761"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/clang%20in%20llvm-tools-preview%3F/near/207503761" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/clang.20in.20llvm-tools-preview.3F.html#207503761">(Aug 20 2020 at 09:21)</a>:</h4>
<p>(see <a href="https://github.com/rust-lang/rust/blob/1a22a0ff93d63f738151f096434e732466b4a42e/src/ci/docker/host-x86_64/x86_64-gnu-debug/Dockerfile#L29">https://github.com/rust-lang/rust/blob/1a22a0ff93d63f738151f096434e732466b4a42e/src/ci/docker/host-x86_64/x86_64-gnu-debug/Dockerfile#L29</a>)</p>



<a name="207504016"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/clang%20in%20llvm-tools-preview%3F/near/207504016" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/clang.20in.20llvm-tools-preview.3F.html#207504016">(Aug 20 2020 at 09:25)</a>:</h4>
<p>It might be as easy as adding clang to the list of LLVM tools at: <br>
<a href="https://github.com/rust-lang/rust/blob/1a22a0ff93d63f738151f096434e732466b4a42e/src/bootstrap/lib.rs#L172">https://github.com/rust-lang/rust/blob/1a22a0ff93d63f738151f096434e732466b4a42e/src/bootstrap/lib.rs#L172</a><br>
and setting <code>RUSTBUILD_FORCE_CLANG_BASED_TESTS</code> in an appropriate <code>dist</code> docker image.</p>



<a name="207504066"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/clang%20in%20llvm-tools-preview%3F/near/207504066" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/clang.20in.20llvm-tools-preview.3F.html#207504066">(Aug 20 2020 at 09:26)</a>:</h4>
<p>Although I am absolutely certain that it will not be as easy as just that <code>:)</code></p>



<a name="207504597"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/clang%20in%20llvm-tools-preview%3F/near/207504597" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/clang.20in.20llvm-tools-preview.3F.html#207504597">(Aug 20 2020 at 09:33)</a>:</h4>
<p>Well, we shouldn't just set <code>RUSTBUILD_FORCE_CLANG_BASED_TESTS</code>; presumably we should modify <code>src/bootstrap/native.rs</code> to add <code>"clang"</code> to <code>enabled_llvm_projects</code> on some subset of platforms.</p>



<a name="207504676"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/clang%20in%20llvm-tools-preview%3F/near/207504676" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/clang.20in.20llvm-tools-preview.3F.html#207504676">(Aug 20 2020 at 09:34)</a>:</h4>
<p>And then yeah, there will almost certainly be other files that have to be shipped to make that usable. But it's worth a try.</p>



<a name="207504740"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/clang%20in%20llvm-tools-preview%3F/near/207504740" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/clang.20in.20llvm-tools-preview.3F.html#207504740">(Aug 20 2020 at 09:35)</a>:</h4>
<p>Yes, of course, my proposal was not a clean solution, more something to point at the appropriate  bits that already exist in <code>bootstrap</code></p>



<a name="207504819"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/clang%20in%20llvm-tools-preview%3F/near/207504819" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/clang.20in.20llvm-tools-preview.3F.html#207504819">(Aug 20 2020 at 09:36)</a>:</h4>
<p>I'll give that a shot at some point, and see if I can make it work.</p>



<a name="207504850"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/clang%20in%20llvm-tools-preview%3F/near/207504850" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/clang.20in.20llvm-tools-preview.3F.html#207504850">(Aug 20 2020 at 09:36)</a>:</h4>
<p>nice</p>



<a name="207504876"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/clang%20in%20llvm-tools-preview%3F/near/207504876" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/clang.20in.20llvm-tools-preview.3F.html#207504876">(Aug 20 2020 at 09:37)</a>:</h4>
<p>there's still quite some room for improvement for xLTO, especially when it comes to usability</p>



<a name="207504971"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/clang%20in%20llvm-tools-preview%3F/near/207504971" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/clang.20in.20llvm-tools-preview.3F.html#207504971">(Aug 20 2020 at 09:38)</a>:</h4>
<p>Yeah, we're a long way from <code>rustc foo.c bar.rs</code>. :)</p>



<a name="207504991"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/clang%20in%20llvm-tools-preview%3F/near/207504991" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/clang.20in.20llvm-tools-preview.3F.html#207504991">(Aug 20 2020 at 09:38)</a>:</h4>
<p>But hopefully this will make it easier.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>